package util;

import entity.*;
import net.sf.json.JSONObject;
import service.WxService;

/**
 * Created by Administrator on 2019/1/23.
 */
public class CreateMenu {

    public static void main (String[] args){
        Button btn = new Button();

        btn.getButton().add(new ClickButton("一级点击","1"));
        btn.getButton().add(new ViewButton("一级跳转","http://www.baidu.com"));

        SubButton sb =new SubButton("子菜单");
        sb.getSub_button().add(new PhotoOrAlbumButton("传图","31"));
        sb.getSub_button().add(new ClickButton("点我","32"));
        sb.getSub_button().add(new ViewButton("地图","http://j74x6c.natappfree.cc"));

        btn.getButton().add(sb);

        JSONObject jsonObject =JSONObject.fromObject(btn);
        System.out.println(jsonObject);

        String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";
        url = url.replace("ACCESS_TOKEN", WxService.getAccessToken());
        String result = Util.post(url,jsonObject.toString());

//        String url2 = " https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN";
//        url2 = url2.replace("ACCESS_TOKEN", WxService.getAccessToken());
//
//        String result2 = Util.get(url2);



        System.out.println(result);
//        System.out.println(result2);

    }
}
